-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix ImageMobject
3D rotation/flipping and remove resampling algorithms lanczos
(antialias
), box
and hamming
#4266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chopan050
wants to merge
11
commits into
ManimCommunity:main
Choose a base branch
from
chopan050:fix-image-rotation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+105
−102
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7b059ef
to
6aea7b6
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaking changes
This PR introduces breaking changes
needs discussion
Things which needs to be discussed before implemented.
pr:bugfix
Bug fix for use in PRs solving a specific issue:bug
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2412
Therefore, also fixes its duplicates #2979, #3131, #3559 and part of #3646.
As I commented in the "Image issues Tracking" issue #3482:
The solution I described, which was also discussed in some of the issues I mentioned before, consists of leveraging
PIL.Image.Image.transform()
to rewriteCamera.display_image_mobject()
. Figuring out how to usePIL.Image.Image.transform()
was the actual challenge, but this StackOverflow discussion shed light on this problem (thank you very much, mmgp ❤️).I'll use the example provided by @hennels on issue #2412 (thanks!). I'm including the generated video after applying these changes.
There are still some issues, though:
ImageIn3D_new.mp4
However, this PR must introduce a...
BREAKING CHANGE 💥
PIL.Image.Image.transform()
only supports theNEAREST
,BILINEAR
andBICUBIC
resampling algorithms. It does not supportBOX
,HAMMING
orLANCZOS
. That is a big issue, sinceCamera.display_image_mobject()
runs for every frame and you can't opt out of using it. Even in 2D scenes where there's no actual need for a perspective transform, one still has to account for possible shears of an image, which seems to require.transform()
anyways. There doesn't seem to exist a proper fix to the 3D rotation / flipping / shear issue without usingPIL.Image.Image.transform()
.If such fix does not exist, then it is not possible to support
BOX
,HAMMING
orLANCZOS
. Therefore, I removed support for them in this PR by removing the following constants:I also rewrote
tests/test_graphical_units/test_img_and_svg.py::test_ImageInterpolation
to remove those now unsupported resamping algorithms and rewroteAbstractImageMobject.set_resampling_algorithm()
to better capture invalid values.Reviewer Checklist